package written_examination_questions;

import java.util.Scanner;

public class Demo20251105 {
    // 游游的水果大礼包
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long m = in.nextInt();
        long a = in.nextInt();
        long b = in.nextInt();
        long ret = 0;
        for (long x = 0; x <= Math.min(n / 2, m); x++) { // 1 号礼包个数
            long y = Math.min(n - 2 * x, (m - x) / 2); // 2 号礼包个数
            ret = Math.max(ret, a * x + b * y);
        }
        System.out.println(ret);
    }
    
}
